package com.frogs.ucenter.v1.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.frogs.framework.base.web.BaseController3;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.api.response.FailResponse;
import com.frogs.system.web.api.response.Response;
import com.frogs.system.web.exception.AppBaseException;
import com.frogs.ucenter.v1.request.TagGoodsRelationListRequest;
import com.frogs.ucenter.v1.response.DefaultResponse;
import com.frogs.ucenter.v1.service.GoodsEvaluateService;
import com.frogs.ucenter.v1.util.ApiConstants;

@Controller(ApiConstants.VERSION + "tagGoodsRelationController")
@RequestMapping("/" + ApiConstants.VERSION )
public class TagGoodsRelationController extends BaseController3 {
	
	@Resource(name=ApiConstants.VERSION + "goodsEvaluateService")
	private GoodsEvaluateService goodsEvaluateService;
    
	private static final String ROOT = "/tag";
    private static final String TAG_GOODS_LIST = ROOT + "/goods/list";

    /**这里不应该通过查询评价再去汇总该商品的标签，查询过程可能会慢，
     * 同时也不利于后期商品标签的数据整理，应该通过线下去整理汇总
     * by wushubin
     * */
	@RequestMapping({TAG_GOODS_LIST})
    public Response tagGoodsList(HttpServletRequest httpRequest) {
    	Request request = new TagGoodsRelationListRequest();
    	Response response = new DefaultResponse();
    	try {
    		request.parse(httpRequest);
    		// TO_DO 需要重新实现
    		response.setTip("获取标签列表成功!");
    	} catch(Exception e) {
    		response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
    	}
    	return response;
    }
    
}